package netmorph.model.parts;

import netmorph.model.NetmorphModel;

public class BasalElongPart extends NetmorphModelElongPart {


	public BasalElongPart(ElongInputModel input, ElongOutputModel output, NetmorphModel model) 
	{
		super(input, output, model);
	}

	@Override
	public void init() {
		x = new double[]{ input.getBERIPDFMean(), input.getBERIPDFStdev(), input.getBTSEMBranchPDFMean(), input.getBTSEMBranchPDFStdev() };  
		y = new double[4];
		yt = new double[] { output.getTargetBTSLenMean(), output.getTargetBTSLenStdev(), output.getTargetBISLenMean(), output.getTargetBISLenStdev() }; 
	}

	@Override
	public void setParameters() {
		input.setBERIPDFMean(x[0]);
		input.setBERIPDFStdev(x[1]);
		input.setBTSEMBPDFMean(x[2]);
		input.setBTSEMBPDFStdev(x[3]);
	}

	@Override
	public void modelComputed(NetmorphModel model) {
		double tsm = model.getLastStats().basalTermSegLenDist().mean();
		double tss = model.getLastStats().basalTermSegLenDist().stdev();
		double ism = model.getLastStats().basalIntSegLenDist().mean();
		double iss = model.getLastStats().basalIntSegLenDist().stdev();
		y = new double[] { tsm, tss, ism, iss };
	}

	@Override
	public boolean isDone() {
		return true;
	}

	@Override
	public String getName() {
		return "BasalElong";
	}
}
